<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>

<body>

    <!-- $nextTick()将回调延迟到下次 DOM 更新循环之后执行 -->
    <div id="app">
        <div class="hello">
            <div>
                <button id="firstBtn" @click="testClick()" ref="aa">{{testMsg}}</button>
            </div>
        </div>
    </div>

    <script>
        let app = new Vue({
            el: "#app",
            data: {
                testMsg: "原始值",
            },


            created() {
                console.log('created');
            },

            mounted() {

                console.log('mounted');
            },

            methods: {
                testClick: function() {
                    let that = this;
                    that.testMsg = "修改后的值";
                    console.log(that.$refs.aa.innerText + 'innerText'); //that.$refs.aa获取指定DOM，输出：原始值
                }

                // testClick:function(){
                //     let that = this
                //     that.testMsg = "修改后的值"
                //     this.$nextTick(function(){
                //         console.log(that.$refs.aa.innerText+'innerText'); ////输出：修改后的值
                //     })
                // }
            },



            // function pp() {
            //     this.$nextTick(function() {
            //         // 将回调延迟到下次dom更新循环后执行
            //     })
            // }





        })
    </script>
</body>

</html>